<?php
//    require_once('class.BasicAnalyzer.php');
    /**
    * 用于提取 Youtube 网站的视频
    *
    */
    class YoutubeAnalyzer extends BasicAnalyzer implements Analyzer
    {
        public $features = array("url" => "/http:\/\/www.youtube.com\/watch\?.*/i");

        public function analyze($content, $url)
        {

            preg_match('!<title>(.*?)</title>!', $content, $matches);
            $title = $descr = $matches[1];
            preg_match('!video_id=.*&t=[^\"&]*!', $content, $matches);
            $vurl = 'http://youtube.com/get_video?'.$matches[0];
            $referer = $url;
            $tags = array('sr_youtube');
            $category = "";
            $ext = "";
            $pub_date ="";
            $author ="";
            //===================================
            $rv = array(
                array(
                    "url" => $vurl, 
                    "title" => $title,
                    "descr" => $descr,
                    "referer" => $referer,
                    "tags" => $tags, 
                    "category" => $category,
                    "ext" => $ext,
                    "pub_date" => $pub_date,
                    "author" => $author
                    )
                );

            
            //===================================

            return $rv;
        }
    }

?>
